"""
Main.py - Wires up the ArffBarfer with the DataFetchers and FeatureGenerators.

Author: Miles Malerba
"""

from ArffBarfer import *
from DataFetchers import *
from FeatureGenerators import *

def main():
  """Main method."""
  scale_data_fetcher = ScaleDataFetcher(num_files=1000)
  # Feature generators - ones that have alrerady been generated are commented
  # out to avoid unecissary processing.
  feature_generators = [
    ('sacle_unigram',
      UnigramFeatureGenerator(scale_data_fetcher, 30)),
    ('scale_unigram_neg',
     UnigramNegationFeatureGenerator(scale_data_fetcher, 30)),
    ('scale_adjective',
      AdjectiveFeatureGenerator(scale_data_fetcher, 30)),
    ('scale_adjective_neg',
      AdjectiveNegationFeatureGenerator(scale_data_fetcher, 30))
  ]
  generate_arffs(scale_data_fetcher, feature_generators)

  rt_data_fetcher = RottenTomatoesDataFetcher()
  feature_generators = [
    ('rt_unigram',
      UnigramFeatureGenerator(rt_data_fetcher, 30)),
    ('rt_unigram_neg',
      UnigramNegationFeatureGenerator(rt_data_fetcher, 30)),
    ('rt_adjective',
      AdjectiveFeatureGenerator(rt_data_fetcher, 30)),
    ('rt_adjective_neg',
      AdjectiveNegationFeatureGenerator(rt_data_fetcher, 30))
  ]
  generate_arffs(rt_data_fetcher, feature_generators)


def generate_arffs(data_fetcher, feature_generators):
  """Run multiple feature generators on a corpus.

  Parameters:
    data_fetcher       - The data fetcher for the corpus.
    feature_generators - A list of tuples consisting of labels for the files and
                         feature generators to generate them.
  """
  barfer = ArffBarfer(data_fetcher)
  for f_gen in feature_generators:
    barfer.generate_arffs(*f_gen)


if __name__ == '__main__':
  main()
